<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>更新票号updateTicketNum.html</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<style>
		body{
			background:#f1f1f1;
		}
		.title{
			height:45px;
			line-height:45px;
			margin-left:4px;
			font-size:14px;
			font-weight:900;
			width:1032px;
		}
		.quare{
			margin:0 7px 0 11px;
			position:relative;
			top:3px;
			display:inline-block;
			width:4px;
			height:16px;
			background:#00aa98;
		}
		.contentBox{
			width:1032px;
			background:white;
			margin-left:14px;
		}
		.times{
			line-height:40px;
			margin-left:20px;
		}
		.content{
			padding-bottom:20px;
		}
		.content table{
			width:990px;
			margin-left:20px;
		}
		.content table th,td{
			height:30px;
			border:1px solid #e7e7e7;
		}
		.content table th{
			background:#f1f1f1;
		}
		.backButton{
			text-align:center;
			padding:20px 0 ;
		}
		.peopleTotal{
			display:inline-block;
			float:right;
			font-weight:normal;
		}
		.peopleTotal span{
			color:#00aa98;
		}
		.head{
			line-height:45px;
	
		}
		.sure{
			background-color:#f9a61a;
		}
		.cancel{
			background: #afb1b0;
   			margin-left: 10px;
		}
		.btnBox{
			text-align:right;
			margin-right:20px;
			padding-bottom:20px;
		}
	</style>
	<body>
		<p class='head'>
			<span style='margin-left:15px;'>订单号：<span class='orderNo' id="order_id"></span></span>
			<span style='margin-left:15px;'>(平台订单号:<span class='orderPfNo' id="platformOrderId"></span>)</span>
			<span style='margin-left:15px;'>客户:<span class='orderCus' id="createUserName"></span></span>
			<span style='margin-left:15px;'>状态:<span class='orderStatus' id="status"></span></span>
			<span style='margin-left:15px;'>订单总价:<span class='orderPrice' id="price"></span>元</span>
		</p>
		<p class='title'>
			<span><i class='quare'></i>航班信息</span>
		</p>
		<div class='contentBox'>
			<div class='content'>
				<p class='times'>第 1 程航班</p>
				<table>
					<tr>
						<th>序号</th>
						<th>行程</th>
						<th>航班号</th>
						<th>舱位</th>
						<!-- <th>机型</th> -->
						<th>起飞日期</th>
						<th>出发时间</th>
						<th>到达时间</th>
					</tr>
					<tbody class="clear">
					</tbody>
				</table>
			</div>
			
			<!-- 分页功能没未有添加 -->
		</div>
		<p class='title'>
			<span><i class='quare'></i>旅客与出票信息</span>
			<span class='peopleTotal'>总计：成人<span id="audlt"></span>人,儿童<span id="child"></span>人,婴儿<span id="infant"></span>人</span>
		</p>
		<div class='contentBox'>
			<div class='content passengerTicket' style='padding-top:20px;'>
				<table>
					<tr>
						<th>序号</th>
						<th>旅客姓名</th>
						<th>性别</th>
						<th>旅客类型</th>
						<th>证件类别</th>
						<th>证件号</th>
						<th>证件有效期</th>
						<th>出生日期</th>
						<th>手机号</th>
						<th>票号</th>
						<th>成人</th>
					</tr>
					<tbody class="clearPassenger"></tbody>
				</table>
			</div>
			
			<div class='btnBox'>
			<button class='Dolo_btn sure'>确认</button>
			<button class='Dolo_btn cancel'>取消</button>
			</div>
		</div>
		<p class='title'>
			<span><i class='quare'></i>票价与支付</span>
		</p>
		<div class='contentBox'>
			<div class='content' style='padding-top:20px;'>
				<table>
					<tr>
						<th>旅客类型</th>
						<th>票价</th>
						<th>税金</th>
						<th>总费用(单人)</th>
						<th>旅客人数</th>
						<th>总费用</th>						
					</tr>
					<tbody class="pjzf"></tbody>
				</table>
			</div>
		</div>
		<!-- 
		<div class='backButton'>
			<button class='Dolo_btn back'>返回</button>
		</div>   -->
	</body>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
			<!-- 引入my97日期时间控件 -->
		<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>	
		<script type="text/javascript" src="../js/common.js" ></script>
		<script>
		 var url = document.location.href.toString();
		 var u = url.split("=");
		 //alert(u[1]) 获取通过URL向下一个页面传过来的id值
		 //订单详情第一个接口
		  $.ajax({
				type:"get",
				url:"../order/"+u[1]+"?temp="+Math.random(),
				//url:"../JSON/orderDetail.json",
				dataType:"json",
				async:true,
				success:function(data){
					
					$("#order_id").text(data.data.id);
					$("#platformOrderId").text(data.data.platformOrderId);
					$("#createUserName").text(data.data.createUserName);
					$("#status").text(commomFun.orderStatusStr(data.data.status));
					$("#price").text(data.data.totalPrice);
					
					}
				})
		 //第二个接口
		  $.ajax({
				type:"get",
				url:"../order/"+u[1]+"/itinery?temp="+Math.random(),
				//url:"../JSON/orderDetail2.json",
				dataType:"json",
				async:true,
				success:function(data){
					$(".clear").empty();
					var str="";
					
					for(var i=0;i<data.data.list.length;i++){
						str+='<tr>'+
						'<td>'+data.data.list[i].index+'</td>'+
						'<td>'+data.data.list[i].departureAirport+"("+data.data.list[i].departureAirportCode+")"+data.data.list[i].departureAirportTerminal+"-"+data.data.list[i].arriveAirport+"("+data.data.list[i].arriveAirportCode+")"+data.data.list[i].arriveAirportTerminal+'</td>'+
						'<td>'+data.data.list[i].flightNumber+'</td>'+
						'<td>'+commomFun.cabinStatusStr(data.data.list[i].seatClass)+'</td>'+
						//'<td>'+data.data.list[i].invLegCabinId+'</td>'+
						'<td>'+data.data.list[i].departureDate+'</td>'+
						'<td>'+data.data.list[i].departureTime+'</td>'+
						'<td>'+data.data.list[i].arriveAirportTime+'</td>'+
						'</tr>';
							
						}
					$(".clear").append(str);
						
					}
				})
				
				//第三个接口 旅客与出票信息
		
		  $.ajax({
				type:"get",
				url:"../order/"+u[1]+"/passenger?temp="+Math.random(),
				//url:"../JSON/orderDetail3.json",
				dataType:"json",
				async:true,
				success:function(data){
				
					$(".clearPassenger").empty();
					var str="";
					var adult=0;//初始化成人的人数
					var child=0;//初始化儿童的人数
					var infant=0;//初始化婴儿的人数
					for(var i=0;i<data.data.list.length;i++){
						if(data.data.list[i].type==1){
							adult++;
						}
						if(data.data.list[i].type==2){
							child++;
						}
						if(data.data.list[i].type==3){
							infant++;
						}
						
						str+='<tr>'+
						'<td class="update_id">'+data.data.list[i].id+'</td>'+
						'<td>'+data.data.list[i].chineseSurname+data.data.list[i].chineseName+'</td>'+
						'<td>'+commomFun.genderStr(data.data.list[i].gender)+'</td>'+
						'<td>'+commomFun.typeNumStr(data.data.list[i].type)+'</td>'+
						'<td>'+commomFun.certificateTypeStr(data.data.list[i].certificateType)+'</td>'+
						'<td>'+data.data.list[i].certificateNumber+'</td>'+
						'<td>'+data.data.list[i].certificateExpireDate+'</td>'+
						'<td>'+data.data.list[i].birthDate+'</td>'+
						'<td>'+data.data.list[i].mobile+'</td>'+
						'<td><input class="updt" type="text" value="'+commomFun.toEmptyString(data.data.list[i].ticketNumber)+'"></td>'+
						'<td></td>'+
						'</tr>';
							
						}

					$("#audlt").text(adult);
					$("#child").text(child);
					$("#infant").text(infant);
					$(".clearPassenger").append(str);
						
					}
				})
				
				$(".sure").click(function(){
					var len=$(".passengerTicket>table>.clearPassenger>tr").length;//获取表格行数
					var dataArr = [];	//定义数组list用于装每条所需的数据	
					for(var i=0;i<len;i++){
						var json={};
						json.ticketNumber=$(".updt").eq(i).val();
						if(json.ticketNumber==""){
							layer.msg("请输入所有票号",{icon: 2,time:2000},function(){
								return false
							})
							return false
						}
						json.passengerId=$(".update_id").eq(i).text();
						dataArr.push(json);
					}
					//将得到的数据传输给后台
					 $.ajax({
							type:"post",
							url:"../order/"+u[1]+"/ticket?temp="+Math.random(),
							contentType:'application/json;charset=utf-8',
							data:JSON.stringify(dataArr),
							async:true,
							success:function(data){
								var data=JSON.parse(data);
								//alert(data.message);
								//layer.msg(data.message);
								if(data.status.toString()=="1001"){
									layer.msg(data.message, {icon: 1,time:1000},function(){
										var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
										parent.layer.close(index);//关闭弹窗
									});			
								}else{
									layer.msg(data.message, {icon: 2,time:1000})
								}
							}
						});
					
					
				});
		 
		 
			//第四个接口 票价与支付
			$.ajax({
				type:"get",
				url:"../order/"+u[1]+"/pjyzf?temp="+Math.random(),
				dataType:"json",
				async:true,
				success:function(data){
					$(".pjzf").empty();
					var str="";					
					for(var i=0;i<data.data.length;i++){
						str+='<tr>'+
						'<td>'+commomFun.typeNumStr(data.data[i].passengerType)+'</td>'+
						'<td>'+data.data[i].price+'</td>'+
						'<td>0</td>'+
						'<td>'+data.data[i].price+'</td>'+
						'<td>'+data.data[i].passengerTotal+'</td>'+
						'<td>'+data.data[i].totalPrice+'</td>'+
						'</tr>';
							
						}
					$(".pjzf").append(str);
					
					
					}
				})
		 
		 
		 
		  //取消执行关闭窗口
  		$(".cancel").click(function(){
  			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
 				 parent.layer.close(index);
  		});
		</script>		
</html>
